﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.HDROutputSettings
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using System.Runtime.CompilerServices;
using UnityEngine.Bindings;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Scripting;

#nullable disable
namespace UnityEngine
{
  /// <summary>
  ///   <para>Provides access to HDR display settings and information.</para>
  /// </summary>
  [UsedByNativeCode]
  [NativeHeader("Runtime/GfxDevice/HDROutputSettings.h")]
  public class HDROutputSettings
  {
    private int m_DisplayIndex;
    /// <summary>
    ///   <para>The list of currently connected displays with possible HDR availability.</para>
    /// </summary>
    public static HDROutputSettings[] displays = new HDROutputSettings[1]
    {
      new HDROutputSettings()
    };
    private static HDROutputSettings _mainDisplay = HDROutputSettings.displays[0];

    internal HDROutputSettings() => this.m_DisplayIndex = 0;

    internal HDROutputSettings(int displayIndex) => this.m_DisplayIndex = displayIndex;

    /// <summary>
    ///   <para>The HDROutputSettings for the main display.</para>
    /// </summary>
    public static HDROutputSettings main => HDROutputSettings._mainDisplay;

    /// <summary>
    ///   <para>Describes whether HDR output is currently active on the display. It is true if this is the case, and @@false@ otherwise.</para>
    /// </summary>
    public bool active => HDROutputSettings.GetActive(this.m_DisplayIndex);

    /// <summary>
    ///   <para>Describes whether HDR is currently available on your primary display and that you have HDR enabled in your Unity Project. It is true if this is the case, and false otherwise.</para>
    /// </summary>
    public bool available => HDROutputSettings.GetAvailable(this.m_DisplayIndex);

    /// <summary>
    ///   <para>Describes whether Unity performs HDR tonemapping automatically.</para>
    /// </summary>
    public bool automaticHDRTonemapping
    {
      get => HDROutputSettings.GetAutomaticHDRTonemapping(this.m_DisplayIndex);
      set => HDROutputSettings.SetAutomaticHDRTonemapping(this.m_DisplayIndex, value);
    }

    /// <summary>
    ///   <para>The ColorGamut used to output to the active HDR display.</para>
    /// </summary>
    public ColorGamut displayColorGamut
    {
      get => HDROutputSettings.GetDisplayColorGamut(this.m_DisplayIndex);
    }

    /// <summary>
    ///   <para>The RenderTextureFormat of the display buffer for the active HDR display.</para>
    /// </summary>
    public RenderTextureFormat format
    {
      get
      {
        return GraphicsFormatUtility.GetRenderTextureFormat(HDROutputSettings.GetGraphicsFormat(this.m_DisplayIndex));
      }
    }

    /// <summary>
    ///   <para>The Experimental.Rendering.GraphicsFormat of the display buffer for the active HDR display.</para>
    /// </summary>
    public GraphicsFormat graphicsFormat
    {
      get => HDROutputSettings.GetGraphicsFormat(this.m_DisplayIndex);
    }

    /// <summary>
    ///   <para>The base luminance of a white paper surface in nits or candela per square meter (cd/m2).</para>
    /// </summary>
    public float paperWhiteNits
    {
      get => HDROutputSettings.GetPaperWhiteNits(this.m_DisplayIndex);
      set => HDROutputSettings.SetPaperWhiteNits(this.m_DisplayIndex, value);
    }

    /// <summary>
    ///   <para>Maximum input luminance at which gradation is preserved even when the entire screen is bright.</para>
    /// </summary>
    public int maxFullFrameToneMapLuminance
    {
      get => HDROutputSettings.GetMaxFullFrameToneMapLuminance(this.m_DisplayIndex);
    }

    /// <summary>
    ///   <para>Maximum input luminance at which gradation is preserved when 10% of the screen is bright.</para>
    /// </summary>
    public int maxToneMapLuminance => HDROutputSettings.GetMaxToneMapLuminance(this.m_DisplayIndex);

    /// <summary>
    ///   <para>Minimum input luminance at which gradation is identifiable.</para>
    /// </summary>
    public int minToneMapLuminance => HDROutputSettings.GetMinToneMapLuminance(this.m_DisplayIndex);

    /// <summary>
    ///   <para>Describes whether the user has requested to change the HDR Output Mode. It is true if this is the case, and false otherwise.</para>
    /// </summary>
    public bool HDRModeChangeRequested
    {
      get => HDROutputSettings.GetHDRModeChangeRequested(this.m_DisplayIndex);
    }

    /// <summary>
    ///   <para>Use this function to request a change in the HDR Output Mode and in the value of HDROutputSettings.active.</para>
    /// </summary>
    /// <param name="enabled">Indicates whether HDR should be enabled.</param>
    public void RequestHDRModeChange(bool enabled)
    {
      HDROutputSettings.RequestHDRModeChangeInternal(this.m_DisplayIndex, enabled);
    }

    /// <summary>
    ///   <para>Sets the base luminance of a white paper surface in nits or candela per square meter (cd/m2).</para>
    /// </summary>
    /// <param name="paperWhite">The brightness of paper white in nits.</param>
    [Obsolete("SetPaperWhiteInNits is deprecated, please use paperWhiteNits instead.")]
    public static void SetPaperWhiteInNits(float paperWhite)
    {
      int displayIndex = 0;
      if (!HDROutputSettings.GetAvailable(displayIndex))
        return;
      HDROutputSettings.SetPaperWhiteNits(displayIndex, paperWhite);
    }

    [FreeFunction("HDROutputSettingsBindings::GetActive", HasExplicitThis = false, ThrowsException = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool GetActive(int displayIndex);

    [FreeFunction("HDROutputSettingsBindings::GetAvailable", HasExplicitThis = false, ThrowsException = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool GetAvailable(int displayIndex);

    [FreeFunction("HDROutputSettingsBindings::GetAutomaticHDRTonemapping", HasExplicitThis = false, ThrowsException = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool GetAutomaticHDRTonemapping(int displayIndex);

    [FreeFunction("HDROutputSettingsBindings::SetAutomaticHDRTonemapping", HasExplicitThis = false, ThrowsException = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SetAutomaticHDRTonemapping(int displayIndex, bool scripted);

    [FreeFunction("HDROutputSettingsBindings::GetDisplayColorGamut", HasExplicitThis = false, ThrowsException = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern ColorGamut GetDisplayColorGamut(int displayIndex);

    [FreeFunction("HDROutputSettingsBindings::GetGraphicsFormat", HasExplicitThis = false, ThrowsException = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern GraphicsFormat GetGraphicsFormat(int displayIndex);

    [FreeFunction("HDROutputSettingsBindings::GetPaperWhiteNits", HasExplicitThis = false, ThrowsException = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern float GetPaperWhiteNits(int displayIndex);

    [FreeFunction("HDROutputSettingsBindings::SetPaperWhiteNits", HasExplicitThis = false, ThrowsException = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SetPaperWhiteNits(int displayIndex, float paperWhite);

    [FreeFunction("HDROutputSettingsBindings::GetMaxFullFrameToneMapLuminance", HasExplicitThis = false, ThrowsException = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern int GetMaxFullFrameToneMapLuminance(int displayIndex);

    [FreeFunction("HDROutputSettingsBindings::GetMaxToneMapLuminance", HasExplicitThis = false, ThrowsException = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern int GetMaxToneMapLuminance(int displayIndex);

    [FreeFunction("HDROutputSettingsBindings::GetMinToneMapLuminance", HasExplicitThis = false, ThrowsException = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern int GetMinToneMapLuminance(int displayIndex);

    [FreeFunction("HDROutputSettingsBindings::GetHDRModeChangeRequested", HasExplicitThis = false, ThrowsException = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool GetHDRModeChangeRequested(int displayIndex);

    [FreeFunction("HDROutputSettingsBindings::RequestHDRModeChange", HasExplicitThis = false, ThrowsException = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void RequestHDRModeChangeInternal(int displayIndex, bool enabled);
  }
}
